package com.intramirror.product.service.impl;

import com.intramirror.product.entity.OrderLineSpuEntity;
import com.intramirror.product.entity.Product;
import com.intramirror.product.entity.SuperiorProduct;
import com.intramirror.product.entity.Tag;
import com.intramirror.product.mapper.ProductMapper;
import com.intramirror.product.mapper.SuperiorProductMapper;
import com.intramirror.product.mapper.TagMapper;
import com.intramirror.product.service.IProductService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.netflix.discovery.converters.Auto;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements IProductService {

    private final static Logger LOGGER = LoggerFactory.getLogger(ProductServiceImpl.class);

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    SuperiorProductMapper superiorProductMapper;

    @Autowired
    TagMapper tagMapper;

    @Override
    public int deleteByPrimaryKey(Long productId) {
        return productMapper.deleteByPrimaryKey(productId);
    }

    @Override
    public int insert(Product record) {
        return productMapper.insert(record);
    }

    @Override
    public int insertSelective(Product record) {
        return productMapper.insertSelective(record);
    }

    @Override
    public Product selectByPrimaryKey(Long productId) {
        return productMapper.selectByPrimaryKey(productId);
    }

    @Override
    public Product selectByParameter(Product record) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Product record) {
        return productMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(Product record) {
        return productMapper.updateByPrimaryKeyWithBLOBs(record);
    }

    @Override
    public int updateByPrimaryKey(Product record) {
        return productMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Map<String, Object>> getProductBySpuId(Map<String, Object> condMap) {
        return productMapper.getProductBySpuId(condMap);
    }

    @Override
    public Map<String, Object> getProductCount(Long spuId) {
        return productMapper.getProductCount(spuId);
    }

    @Override
    public OrderLineSpuEntity getSpuByOrderLineNum(String orderLineNum) {
        return productMapper.getSpuByOrderLineNum(orderLineNum);
    }

    @Override
    public List<Map<String, Object>> getProductBySpuSku(OrderLineSpuEntity orderLineSpuEntity) {
        return productMapper.getProductBySpuSku(orderLineSpuEntity);
    }

    @Override
    public void saveSuperiorProduct(SuperiorProduct superiorProduct) {
        superiorProductMapper.insertSelective(superiorProduct);
    }

    @Override
    public OrderLineSpuEntity getSpuByProductSku(Long skuId) {
        return productMapper.getSpuByProductSku(skuId);
    }

    @Override
    public List<Map<String, Object>> getProductByConditions(Map<String, Object> params) {
        return productMapper.getProductByConditions(params);
    }

    @Override
    public int countProductByConditions(Map<String, Object> params) {
        return productMapper.countProductByConditions(params);
    }

    @Override
    public List<Map<String, Object>> countProductByTagIds(List<String> tagIds){
        return productMapper.countProductByTagIds(tagIds);
    }

    @Override
    public List<Map<String, Object>> getProductByTagId(Long tagId){
        return productMapper.getProductByTagId(tagId);
    }

    @Override
    public List<Tag> selectByType(Long tagType){
        return tagMapper.selectByType(tagType);
    }

}
